/**
 * Created by apple on 2016/11/24.
 */
module.exports = function(sequelize, DataTypes) {
    var Outcall = sequelize.define('Outcall', {
        id: {
            type: DataTypes.INTEGER,
            allowNull: false,
            unique: true,
            primaryKey: true
        },
        doc_id: {
            type: DataTypes.INTEGER,
            allowNull: false
        },
        OutCallDate: {
            type: DataTypes.DATEONLY,
            allowNull: false
        },
        OutCallTime: {
            type: DataTypes.INTEGER
        },
        Number: {
            type: DataTypes.INTEGER
        },
        Remain: {
            type: DataTypes.INTEGER
        },
        OutCallType: {
            type: DataTypes.INTEGER,
            defaultValue: 1
        },
        Status: {
            type: DataTypes.INTEGER,
            defaultValue: 1
        },
        fee: {
            type: DataTypes.DECIMAL,
            allowNull: false
        },
        CreateTime: {
            type: DataTypes.DATE
        },
        remark: {
            type: DataTypes.TEXT
        }
    }, {
        underscored: true,
        'timestamps': false,
        'createdAt': false,
        'updatedAt': false,
        freezeTableName: true
    }, {
        classMethods: {
            associate: function (models) {
                Outcall.belongsTo(models.Doctor, {
                    onDelete: "CASCADE",
                    onUpdate: "CASCADE",
                    foreignKey: {
                        allowNull: false
                    }
                });
                Outcall.hasMany(models.Appointment);
            }
        }
    });
    return Outcall;
};

